package com.mycinema.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.mycinema.dao.CategoryDao;
import com.mycinema.dao.MovieDao;
import com.mycinema.entity.Category;
import com.mycinema.service.CategoryService;

@Service
public class CategoryServiceImpl  implements CategoryService{

	@Autowired
	private CategoryDao categoryDao;
	@Autowired
	private MovieDao movieDao;
	
	public List<Category> getAll() {		
		return categoryDao.getAll();
	}

	public Category getById(int id) {	
		return categoryDao.getById(id);
	}

	public void addCategory(Category category) {
		categoryDao.addCategory(category);		
	}

	public void delete(int id) {
		//先删除该类别的所有电影
		movieDao.deleteByCid(id);
		//删除类别
		categoryDao.delete(id);
	}
	
	

}
